<?php

use Illuminate\Database\Capsule\Manager as DB;

class StoreController extends CommonController
{
    public function indexAction()
    {
        // 获取所有用户门店
        $user = \app\service\auth::getUser();
        $store_ids = \app\modules\Admin\models\storememberModel::where('member_id', $user->id)
            ->pluck('store_id')
            ->toArray();
        $stores = storeModel::whereIn('id', $store_ids ?: [])->where('dianpu_id', 0)->get();
        foreach ($stores as $store) {
            $store->image_first = $store->images_arr[0] ?? '';
            $data[] = $store;
        }

        json(['code' => 1, 'msg' => '', 'data' => $data ?? []]);
    }
}
